package kr.pe.johnkim.waiting.mobile.service;

import kr.pe.johnkim.waiting.mobile.dao.WaitingMemberDao;
import kr.pe.johnkim.waiting.mobile.domain.WaitingMember;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 4. 10.
 */
@Service
public class WaitingMemberServiceImpl implements WaitingMemberService {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(WaitingLogServiceImpl.class);

    @Autowired
    private WaitingMemberDao waitingMemberDao;

    /**
     * 기존에 등록된 정보가 있는지 확인한다.
     *
     * @param waitingMember
     * @return
     */
    @Override
    public WaitingMember selectDuplicate(WaitingMember waitingMember) {
        logger.info("selectDuplicate");
        return this.waitingMemberDao.selectDuplicate(waitingMember);
    }

    /**
     * 멤버를 등록 한다.
     *
     * @param waitingMember
     */
    @Override
    public void registerMember(WaitingMember waitingMember) {
        logger.info("registerMember");
        this.waitingMemberDao.registerMember(waitingMember);
    }

    /**
     * 멤버 정보를 가져 온다.
     *
     * @param waitingMember
     * @return
     */
    @Override
    public WaitingMember selectMemberInformation(WaitingMember waitingMember) {
        logger.info("selectMemberInformation");
        return this.waitingMemberDao.selectMemberInformation(waitingMember);
    }

    /**
     * 멤버 정보를 수정 한다. 현재는 이메일 주소뿐이다.
     *
     * @param waitingMember
     */
    @Override
    public void updateMemberInformation(WaitingMember waitingMember) {
        logger.info("updateMemberInformation");
        this.waitingMemberDao.updateMemberInformation(waitingMember);
    }

    /**
     * 멤버 목록을 가져 온다.
     *
     * @param waitingMember
     * @return
     */
    @Override
    public List<WaitingMember> selectMemberList(WaitingMember waitingMember) {
        logger.info("selectMemberList");
        return this.waitingMemberDao.selectMemberList(waitingMember);
    }

    /**
     * 멤버 총 갯수를 가져 온다.
     *
     * @param waitingMember
     * @return
     */
    @Override
    public WaitingMember selectMemberTotalCount(WaitingMember waitingMember) {
        logger.info("selectMemberTotalCount");
        return this.waitingMemberDao.selectMemberTotalCount(waitingMember);
    }

    /**
     * 멤버의 GCM Registration Id / APNS Device Token 을 업데이트 한다.
     *
     * @param waitingMember
     */
    @Override
    public void updateRegistrationId(WaitingMember waitingMember) {
        logger.info("updateRegistrationId");
        this.waitingMemberDao.updateRegistrationId(waitingMember);
    }

    /**
     * 멤버의 Push Notification 수신 여부를 업데이트 한다.
     *
     * @param waitingMember
     */
    @Override
    public void updateReceiveNotificationYn(WaitingMember waitingMember) {
        logger.info("updateReceiveNotificationYn");
        this.waitingMemberDao.updateReceiveNotificationYn(waitingMember);
    }

    /**
     * 멤버의 활성화 여부를 업데이트 한다.
     *
     * @param waitingMember
     */
    @Override
    public void updateMemberActivateYn(WaitingMember waitingMember) {
        logger.info("updateMemberActivateYn");
        this.waitingMemberDao.updateMemberActivateYn(waitingMember);
    }
}
